home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / DUPL.MOD < prev    next >
Text File  |  1986-09-11  |  4KB  |  57 lines

  1. (*--------------------------------------------------------------------------*)
  2. (*                     Dupl -- Duplicate a character n times                *)
  3. (*--------------------------------------------------------------------------*)
  4.  
  5. FUNCTION Dupl( Dup_char : Char; Dup_Count: INTEGER ) : AnyStr;
  6.  
  7. (*--------------------------------------------------------------------------*)
  8. (*                                                                          *)
  9. (*    Function: Dupl                                                        *)
  10. (*                                                                          *)
  11. (*    Purpose:  Duplicate a character n times                               *)
  12. (*                                                                          *)
  13. (*    Calling Sequence:                                                     *)
  14. (*                                                                          *)
  15. (*       Dup_String := Dupl( Dup_Char: Char; Dup_Count: INTEGER ): AnyStr;  *)
  16. (*                                                                          *)
  17. (*          Dup_Char   --- Character to be duplicated                       *)
  18. (*          Dup_Count  --- Number of times to duplicate character           *)
  19. (*          Dup_String --- Resultant duplicated string                      *)
  20. (*                                                                          *)
  21. (*          Note:  If Dup_Count <= 0, a null string is returned.            *)
  22. (*                                                                          *)
  23. (*    Calls:  None                                                          *)
  24. (*                                                                          *)
  25. (*                                                                          *)
  26. (*    Remarks:                                                              *)
  27. (*                                                                          *)
  28. (*       This routine could be programmed directly in Turbo as:             *)
  29. (*                                                                          *)
  30. (*          VAR                                                             *)
  31. (*             S    : AnyStr;                                               *)
  32. (*                                                                          *)
  33. (*          BEGIN                                                           *)
  34. (*                                                                          *)
  35. (*             FillChar( S[1], Dup_Count, Dup_Char );                       *)
  36. (*             S[0] := CHR( Dup_Count );                                    *)
  37. (*                                                                          *)
  38. (*             Dupl := S;                                                   *)
  39. (*                                                                          *)
  40. (*          END;                                                            *)
  41. (*                                                                          *)
  42. (*--------------------------------------------------------------------------*)
  43.  
  44. BEGIN (* Dupl *)
  45.  
  46.    INLINE(  $16/                   (* PUSH      SS         ; Push stack ptr        *)
  47.             $07/                   (* POP       ES         ; For result addressing *)
  48.             $8B/$4E/$04/           (* MOV       CX,[BP+4]  ; Pick up dup count     *)
  49.             $88/$4E/$08/           (* MOV       [BP+8],CL  ; Store result length   *)
  50.             $8B/$46/$06/           (* MOV       AX,[BP+6]  ; Get char to duplicate *)
  51.             $8D/$7E/$09/           (* LEA       DI,[BP+9]  ; Result address        *)
  52.             $FC/                   (* CLD                  ; Set direction flag    *)
  53.             $F3/$AA                (* REPLSTOSB            ; Perform duplication   *)
  54.          );
  55.  
  56. END   (* Dupl *);
  57.